﻿namespace HRM.CORE
{
    using APP.HELPER.Data.Helper;
    using APP.HELPER.Utils;
    using DevExpress.Utils;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraEditors.Repository;
    using DevExpress.XtraGrid;
    using DevExpress.XtraGrid.Columns;
    using DevExpress.XtraGrid.Views.Base;
    using DevExpress.XtraGrid.Views.Grid;
    using DevExpress.XtraLayout;
    using DevExpress.XtraLayout.Utils;
    using DevExpress.XtraWizard;
    using Dictionary.ERP;
    using HRM.CORE;
    using System; using Extra.ERP;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Diagnostics;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms; using Common;
    using APP.HELPER.Utils.Excel;

    public class xfmImport : XtraForm
    {
        private ComboBoxEdit cboSheet;
        private GridColumn colFieldName;
        private GridColumn colSelectField;
        private IContainer components = null;
        private List<string> FieldName;
        private GridView gbList;
        private GridControl gcList;
        private LabelControl labelControl1;
        private LabelControl labelControl2;
        private LabelControl labelControl3;
        private LabelControl labelControl4;
        private LabelControl labelControl5;
        private LayoutControlGroup layoutControlGroup1;
        private LayoutControlItem layoutControlItem1;
        private LabelControl lbDataRow;
        private LinkLabel lbFix;
        private LinkLabel lbLinkFile;
        private LabelControl lbMessage;
        private LayoutControl lcSheet;
        private ListBoxControl listboxError;
        private int m_Error = 0;
        private int m_Success = 0;
        private MarqueeProgressBarControl mqProgress;
        private string[] ParamName;
        private List<int> ParamNameIndex;
        private RepositoryItemComboBox repSelectField;
        private ButtonEdit txtFilePath;
        private WizardControl wcImport;
        private CompletionWizardPage wpFinish;
        private DevExpress.XtraWizard.WizardPage wpProcessPage;
        private DevExpress.XtraWizard.WizardPage wpSelectField;
        private WelcomeWizardPage wpSelectFile;

        public event SuccessEventHander Success;

        public xfmImport()
        {
            this.InitializeComponent();
            this.lbLinkFile.Text = Application.StartupPath + @"\ImportFile\Employee.xls";
            this.Success = (SuccessEventHander) Delegate.Combine(this.Success, new SuccessEventHander(this.xfmImport_Success));
        }

        private void cboSheet_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.FillField(this.cboSheet.Text);
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        public void FillField(string SheetName)
        {
            SqlHelper helper = new SqlHelper();
            DataTable dataTable = new DataTable();
            List<int> list = new List<int>();
            List<string> list2 = new List<string> { 
                "M\x00e3 nh\x00e2n vi\x00ean", "Họ l\x00f3t", "T\x00ean", "Ng\x00e0y sinh", "Nơi sinh", "Giới t\x00ednh", "Điện thoại di động", "Địa chỉ", "Tạm tr\x00fa", "Chức vụ", "Ng\x00e0y v\x00e0o l\x00e0m", "CMND", "Ng\x00e0y cấp", "Nơi cấp", "Email", "Điện thoại nh\x00e0", 
                "T\x00ecnh trạng sức khỏe", "Stk ng\x00e2n h\x00e0ng", "T\x00ean ng\x00e2n h\x00e0ng", "M\x00e3 số thuế", "Số sổ BHXH", "Ng\x00e0y cấp sổ BHXH", "Số thẻ BHYT", "M\x00e3 chấm c\x00f4ng", "Lương căn bản", "Lương đ\x00f3ng BHXH", "Ng\x00e0y bắt đầu thử việc", "Ng\x00e0y kết th\x00fac thử việc", "M\x00e3 hợp đồng", "Ng\x00e0y k\x00fd hợp đồng", "Ng\x00e0y bắt đầu hợp đồng", "Ng\x00e0y kết th\x00fac hợp đồng", 
                "Quốc tịch", "D\x00e2n tộc", "T\x00f4n gi\x00e1o", "Học vấn", "Ngoại ngữ", "Tin học", "Chuy\x00ean m\x00f4n", "Nơi đ\x00e0o tạo", "Skype", "Yahoo", "Facebook", "Ghi ch\x00fa"
             };
            DataTable table2 = ExcelImport.ReadExcelContents(this.txtFilePath.Text, SheetName);
            if (table2 != null)
            {
                string[] strArray = new string[table2.Columns.Count];
                this.repSelectField.Items.Clear();
                try
                {
                    int index = 0;
                    foreach (DataColumn column in table2.Columns)
                    {
                        if (table2.Rows[0][column.Caption].ToString() != "")
                        {
                            strArray[index] = table2.Rows[0][column.Caption].ToString();
                            this.repSelectField.Items.Add(table2.Rows[0][column.Caption].ToString());
                            index++;
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Kh\x00f4ng thể đọc sheet n\x00e0y! N\x00f3 kh\x00f4ng giống cấu tr\x00fac mặc định của chương tr\x00ecnh!", "Th\x00f4ng B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return;
                }
                foreach (string str in list2)
                {
                    if (str != "")
                    {
                        new SqlDataAdapter("select N'" + str + "' as [FieldName], '' as [SelectField]", helper.ConnectionString).Fill(dataTable);
                    }
                }
                this.gcList.DataSource = dataTable;
                for (int i = 0; i < table2.Columns.Count; i++)
                {
                    this.gbList.SetRowCellValue(i, this.colSelectField, strArray[i]);
                }
            }
        }

        public void FillSheet()
        {
            DataTable table = ExcelImport.ReadSheets(this.txtFilePath.Text);
            if (table != null)
            {
                this.cboSheet.Properties.Items.Clear();
                foreach (DataRow row in table.Rows)
                {
                    this.cboSheet.Properties.Items.Add(row["TABLE_NAME"].ToString());
                }
                if (table.Rows.Count > 0)
                {
                    this.cboSheet.SelectedIndex = 0;
                }
            }
        }

        private void Import()
        {
            DataTable table = ExcelImport.ReadExcelContents(this.txtFilePath.Text, this.cboSheet.Text);
            if (table != null)
            {
                this.ParamNameIndex = new List<int>();
                for (int i = 0; i < this.gbList.RowCount; i++)
                {
                    DataRow dataRow = this.gbList.GetDataRow(i);
                    if (dataRow[1].ToString() != "")
                    {
                        for (int j = 0; j < this.repSelectField.Items.Count; j++)
                        {
                            if (dataRow[1].ToString() == this.repSelectField.Items[j].ToString())
                            {
                                this.ParamNameIndex.Add(j);
                            }
                        }
                    }
                    else
                    {
                        this.ParamNameIndex.Clear();
                        MessageBox.Show("vui l\x00f2ng chọn đầy đủ th\x00f4ng tin cho c\x00e1c trường!", "Th\x00f4ng B\x00e1o");
                        return;
                    }
                }
                HRM_BRANCH hrm_branch = new HRM_BRANCH();
                if (!hrm_branch.Exist("0000000000"))
                {
                    hrm_branch.BranchCode = "0000000000";
                    hrm_branch.BranchName = "Dữ Liệu Nạp Từ Excel(X)";
                    hrm_branch.Insert();
                }
                int num3 = 0;
                foreach (DataRow row in table.Rows)
                {
                    if (num3 == 0)
                    {
                        num3++;
                    }
                    else
                    {
                        HRM_EMPLOYEE hrm_employee = new HRM_EMPLOYEE();
                        try
                        {
                            hrm_employee.BranchCode = "0000000000";
                            hrm_employee.EmployeeCode = row[this.ParamNameIndex[0]].ToString();
                            hrm_employee.FirstName = row[this.ParamNameIndex[1]].ToString();
                            hrm_employee.LastName = row[this.ParamNameIndex[2]].ToString();
                            MyDateTime.GetValueFromString(row[this.ParamNameIndex[3]].ToString());
                            hrm_employee.BirthdayDay = MyDateTime.Day;
                            hrm_employee.BirthdayMonth = MyDateTime.Month;
                            hrm_employee.BirthdayYear = MyDateTime.Year;
                            hrm_employee.BirthPlace = row[this.ParamNameIndex[4]].ToString();
                            if (row[this.ParamNameIndex[5]].ToString() == "Nam")
                            {
                                hrm_employee.Sex = true;
                            }
                            else
                            {
                                hrm_employee.Sex = false;
                            }
                            hrm_employee.CellPhone = row[this.ParamNameIndex[6]].ToString();
                            hrm_employee.MainAddress = row[this.ParamNameIndex[7]].ToString();
                            hrm_employee.ContactAddress = row[this.ParamNameIndex[8]].ToString();
                            hrm_employee.Position = row[this.ParamNameIndex[9]].ToString();
                            try
                            {
                                MyDateTime.GetValueFromString(row[this.ParamNameIndex[10]].ToString());
                                hrm_employee.BeginDate = new DateTime(MyDateTime.Year, MyDateTime.Month, MyDateTime.Day);
                            }
                            catch
                            {
                                hrm_employee.BeginDate = DateTime.Now;
                            }
                            hrm_employee.IDCard = row[this.ParamNameIndex[11]].ToString();
                            try
                            {
                                MyDateTime.GetValueFromString(row[this.ParamNameIndex[12]].ToString());
                                hrm_employee.IDCardDate = new DateTime(MyDateTime.Year, MyDateTime.Month, MyDateTime.Day);
                            }
                            catch
                            {
                                hrm_employee.IDCardDate = DateTime.Now;
                            }
                            hrm_employee.IDCardPlace = row[this.ParamNameIndex[13]].ToString();
                            hrm_employee.Email = row[this.ParamNameIndex[14]].ToString();
                            hrm_employee.HomePhone = row[this.ParamNameIndex[15]].ToString();
                            hrm_employee.Health = row[this.ParamNameIndex[0x10]].ToString();
                            hrm_employee.BankCode = row[this.ParamNameIndex[0x11]].ToString();
                            hrm_employee.BankName = row[this.ParamNameIndex[0x12]].ToString();
                            hrm_employee.IncomeTaxCode = row[this.ParamNameIndex[0x13]].ToString();
                            hrm_employee.InsuranceCode = row[this.ParamNameIndex[20]].ToString();
                            try
                            {
                                MyDateTime.GetValueFromString(row[this.ParamNameIndex[0x15]].ToString());
                                hrm_employee.InsuranceDate = new DateTime(MyDateTime.Year, MyDateTime.Month, MyDateTime.Day);
                            }
                            catch
                            {
                                hrm_employee.InsuranceDate = DateTime.Now;
                            }
                            hrm_employee.HealthInsuranceCode = row[this.ParamNameIndex[0x16]].ToString();
                            hrm_employee.EnrollNumber = row[this.ParamNameIndex[0x17]].ToString();
                            try
                            {
                                hrm_employee.PayForm = 1;
                                hrm_employee.PayMoney = decimal.Parse(row[this.ParamNameIndex[0x18]].ToString());
                                hrm_employee.BasicSalary = decimal.Parse(row[this.ParamNameIndex[0x18]].ToString());
                                hrm_employee.InsuranceSalary = decimal.Parse(row[this.ParamNameIndex[0x19]].ToString());
                            }
                            catch
                            {
                            }
                            try
                            {
                                MyDateTime.GetValueFromString(row[this.ParamNameIndex[0x1a]].ToString());
                                hrm_employee.TestFromDate = new DateTime(MyDateTime.Year, MyDateTime.Month, MyDateTime.Day);
                            }
                            catch
                            {
                                hrm_employee.TestFromDate = DateTime.Now;
                            }
                            try
                            {
                                MyDateTime.GetValueFromString(row[this.ParamNameIndex[0x1b]].ToString());
                                hrm_employee.TestToDate = new DateTime(MyDateTime.Year, MyDateTime.Month, MyDateTime.Day);
                            }
                            catch
                            {
                                hrm_employee.TestToDate = DateTime.Now;
                            }
                            hrm_employee.ContractCode = row[this.ParamNameIndex[0x1c]].ToString();
                            try
                            {
                                MyDateTime.GetValueFromString(row[this.ParamNameIndex[0x1d]].ToString());
                                hrm_employee.ContractSignDate = new DateTime(MyDateTime.Year, MyDateTime.Month, MyDateTime.Day);
                            }
                            catch
                            {
                                hrm_employee.ContractSignDate = DateTime.Now;
                            }
                            try
                            {
                                MyDateTime.GetValueFromString(row[this.ParamNameIndex[30]].ToString());
                                hrm_employee.ContractFromDate = new DateTime(MyDateTime.Year, MyDateTime.Month, MyDateTime.Day);
                            }
                            catch
                            {
                                hrm_employee.ContractFromDate = DateTime.Now;
                            }
                            try
                            {
                                MyDateTime.GetValueFromString(row[this.ParamNameIndex[0x1f]].ToString());
                                hrm_employee.ContractToDate = new DateTime(MyDateTime.Year, MyDateTime.Month, MyDateTime.Day);
                            }
                            catch
                            {
                                hrm_employee.ContractToDate = DateTime.Now;
                            }
                            hrm_employee.Nationality = row[this.ParamNameIndex[0x20]].ToString();
                            hrm_employee.Ethnic = row[this.ParamNameIndex[0x21]].ToString();
                            hrm_employee.Religion = row[this.ParamNameIndex[0x22]].ToString();
                            hrm_employee.Education = row[this.ParamNameIndex[0x23]].ToString();
                            hrm_employee.Language = row[this.ParamNameIndex[0x24]].ToString();
                            hrm_employee.Informatic = row[this.ParamNameIndex[0x25]].ToString();
                            hrm_employee.Professional = row[this.ParamNameIndex[0x26]].ToString();
                            hrm_employee.School = row[this.ParamNameIndex[0x27]].ToString();
                            hrm_employee.Skype = row[this.ParamNameIndex[40]].ToString();
                            hrm_employee.Yahoo = row[this.ParamNameIndex[0x29]].ToString();
                            hrm_employee.Facebook = row[this.ParamNameIndex[0x2a]].ToString();
                            hrm_employee.Description = row[this.ParamNameIndex[0x2b]].ToString();
                            hrm_employee.Status = 1;
                            if (hrm_employee.Insert() == "OK")
                            {
                                this.m_Success++;
                            }
                            else
                            {
                                this.listboxError.Items.Add(string.Concat(new object[] { "D\x00f2ng thứ ", num3, " => ", hrm_employee.EmployeeCode, " | ", hrm_employee.FirstName, " ", hrm_employee.LastName, ": Tr\x00f9ng m\x00e3 nh\x00e2n vi\x00ean" }));
                                this.m_Error++;
                            }
                        }
                        catch (Exception exception)
                        {
                            this.listboxError.Items.Add(string.Concat(new object[] { "D\x00f2ng thứ ", num3, " => ", hrm_employee.EmployeeCode, " | ", hrm_employee.FirstName, " ", hrm_employee.LastName, exception.ToString() }));
                            this.m_Error++;
                        }
                        this.lbDataRow.Text = "Đang nạp dữ liệu... " + hrm_employee.EmployeeCode + " | " + hrm_employee.FirstName + " " + hrm_employee.LastName + "...";
                        this.lbDataRow.Refresh();
                        this.mqProgress.Refresh();
                        num3++;
                    }
                }
            }
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(xfmImport));
            SerializableAppearanceObject appearance = new SerializableAppearanceObject();
            this.wcImport = new WizardControl();
            this.lcSheet = new LayoutControl();
            this.cboSheet = new ComboBoxEdit();
            this.layoutControlGroup1 = new LayoutControlGroup();
            this.layoutControlItem1 = new LayoutControlItem();
            this.wpSelectFile = new WelcomeWizardPage();
            this.labelControl5 = new LabelControl();
            this.lbLinkFile = new LinkLabel();
            this.labelControl2 = new LabelControl();
            this.txtFilePath = new ButtonEdit();
            this.labelControl1 = new LabelControl();
            this.wpProcessPage = new DevExpress.XtraWizard.WizardPage();
            this.lbDataRow = new LabelControl();
            this.labelControl3 = new LabelControl();
            this.mqProgress = new MarqueeProgressBarControl();
            this.wpFinish = new CompletionWizardPage();
            this.listboxError = new ListBoxControl();
            this.lbFix = new LinkLabel();
            this.lbMessage = new LabelControl();
            this.wpSelectField = new DevExpress.XtraWizard.WizardPage();
            this.gcList = new GridControl();
            this.gbList = new GridView();
            this.colFieldName = new GridColumn();
            this.colSelectField = new GridColumn();
            this.repSelectField = new RepositoryItemComboBox();
            this.labelControl4 = new LabelControl();
            this.wcImport.BeginInit();
            this.wcImport.SuspendLayout();
            this.lcSheet.BeginInit();
            this.lcSheet.SuspendLayout();
            this.cboSheet.Properties.BeginInit();
            this.layoutControlGroup1.BeginInit();
            this.layoutControlItem1.BeginInit();
            this.wpSelectFile.SuspendLayout();
            this.txtFilePath.Properties.BeginInit();
            this.wpProcessPage.SuspendLayout();
            this.mqProgress.Properties.BeginInit();
            this.wpFinish.SuspendLayout();
            ((ISupportInitialize) this.listboxError).BeginInit();
            this.wpSelectField.SuspendLayout();
            this.gcList.BeginInit();
            this.gbList.BeginInit();
            this.repSelectField.BeginInit();
            base.SuspendLayout();
            this.wcImport.CancelText = "Tho\x00e1t";
            this.wcImport.Controls.Add(this.lcSheet);
            this.wcImport.Controls.Add(this.wpSelectFile);
            this.wcImport.Controls.Add(this.wpProcessPage);
            this.wcImport.Controls.Add(this.wpFinish);
            this.wcImport.Controls.Add(this.wpSelectField);
            this.wcImport.FinishText = "&Ho\x00e0n Th\x00e0nh";
            this.wcImport.HelpText = "&Trợ Gi\x00fap";
            this.wcImport.Name = "wcImport";
            this.wcImport.NextText = "&Tiếp Tục >";
            this.wcImport.Pages.AddRange(new BaseWizardPage[] { this.wpSelectFile, this.wpSelectField, this.wpProcessPage, this.wpFinish });
            this.wcImport.PreviousText = "< &Trở Lại";
            this.wcImport.Text = "C\x00e1c bước nhập danh s\x00e1ch nh\x00e2n vi\x00ean từ tập tin excel";
            this.wcImport.WizardStyle = WizardStyle.WizardAero;
            this.wcImport.SelectedPageChanged += new WizardPageChangedEventHandler(this.wcImport_SelectedPageChanged);
            this.wcImport.NextClick += new WizardCommandButtonClickEventHandler(this.wcImport_NextClick);
            this.lcSheet.Controls.Add(this.cboSheet);
            this.lcSheet.Location = new Point(0x138, 0x3a);
            this.lcSheet.Name = "lcSheet";
            this.lcSheet.Root = this.layoutControlGroup1;
            this.lcSheet.Size = new Size(0x8e, 0x1c);
            this.lcSheet.TabIndex = 10;
            this.lcSheet.Text = "layoutControl1";
            this.lcSheet.Click += new EventHandler(this.layoutControl1_Click);
            this.cboSheet.Location = new Point(0x3d, 2);
            this.cboSheet.Name = "cboSheet";
            this.cboSheet.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.cboSheet.Size = new Size(0x4f, 20);
            this.cboSheet.StyleController = this.lcSheet;
            this.cboSheet.TabIndex = 4;
            this.cboSheet.SelectedIndexChanged += new EventHandler(this.cboSheet_SelectedIndexChanged);
            this.layoutControlGroup1.CustomizationFormText = "layoutControlGroup1";
            this.layoutControlGroup1.EnableIndentsWithoutBorders = DefaultBoolean.True;
            this.layoutControlGroup1.GroupBordersVisible = false;
            this.layoutControlGroup1.Items.AddRange(new BaseLayoutItem[] { this.layoutControlItem1 });
            this.layoutControlGroup1.Location = new Point(0, 0);
            this.layoutControlGroup1.Name = "layoutControlGroup1";
            this.layoutControlGroup1.Padding = new DevExpress.XtraLayout.Utils.Padding(0, 0, 0, 0);
            this.layoutControlGroup1.Size = new Size(0x8e, 0x1c);
            this.layoutControlGroup1.Spacing = new DevExpress.XtraLayout.Utils.Padding(0, 0, 0, 0);
            this.layoutControlGroup1.Text = "layoutControlGroup1";
            this.layoutControlGroup1.TextVisible = false;
            this.layoutControlItem1.Control = this.cboSheet;
            this.layoutControlItem1.CustomizationFormText = "Chọn sheet";
            this.layoutControlItem1.Location = new Point(0, 0);
            this.layoutControlItem1.Name = "layoutControlItem1";
            this.layoutControlItem1.Size = new Size(0x8e, 0x1c);
            this.layoutControlItem1.Text = "Chọn sheet";
            this.layoutControlItem1.TextSize = new Size(0x37, 13);
            this.wpSelectFile.Controls.Add(this.labelControl5);
            this.wpSelectFile.Controls.Add(this.lbLinkFile);
            this.wpSelectFile.Controls.Add(this.labelControl2);
            this.wpSelectFile.Controls.Add(this.txtFilePath);
            this.wpSelectFile.Controls.Add(this.labelControl1);
            this.wpSelectFile.Name = "wpSelectFile";
            this.wpSelectFile.Size = new Size(0x1a1, 0xae);
            this.wpSelectFile.Text = "Lựa chọn tập tin excel";
            this.labelControl5.AllowHtmlString = true;
            this.labelControl5.Appearance.Options.UseTextOptions = true;
            this.labelControl5.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.labelControl5.AutoSizeMode = LabelAutoSizeMode.None;
            this.labelControl5.Location = new Point(3, 0x98);
            this.labelControl5.Name = "labelControl5";
            this.labelControl5.Size = new Size(0x19b, 0x12);
            this.labelControl5.TabIndex = 0x11;
            this.labelControl5.Text = "Lưu \x00fd: Đ\x00f3ng tập tin cần nạp trước khi thực hiện";
            this.labelControl5.Visible = false;
            this.lbLinkFile.AutoSize = true;
            this.lbLinkFile.BackColor = Color.Transparent;
            this.lbLinkFile.Location = new Point(3, 0x89);
            this.lbLinkFile.Name = "lbLinkFile";
            this.lbLinkFile.Size = new Size(0x86, 13);
            this.lbLinkFile.TabIndex = 0x10;
            this.lbLinkFile.TabStop = true;
            this.lbLinkFile.Text = @"..\ImportFile\Employee.xls";
            this.lbLinkFile.LinkClicked += new LinkLabelLinkClickedEventHandler(this.lbLinkFile_LinkClicked);
            this.labelControl2.AllowHtmlString = true;
            this.labelControl2.Appearance.Options.UseTextOptions = true;
            this.labelControl2.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.labelControl2.AutoSizeMode = LabelAutoSizeMode.None;
            this.labelControl2.Location = new Point(4, 0x6d);
            this.labelControl2.Name = "labelControl2";
            this.labelControl2.Size = new Size(410, 0x19);
            this.labelControl2.TabIndex = 15;
            this.labelControl2.Text = "Mở tập tin <b><i>Employee.xls</i></b> trong thư mục <b>ImportFile</b> tại ổ đĩa c\x00e0i đặt hoặc nhấp v\x00e0o li\x00ean kết sau để xem tập tin mẫu:";
            this.txtFilePath.Location = new Point(3, 0x45);
            this.txtFilePath.Name = "txtFilePath";
            this.txtFilePath.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Glyph, "", -1, true, true, false, ImageLocation.MiddleCenter, (Image) manager.GetObject("txtFilePath.Properties.Buttons"), new KeyShortcut(Keys.None), appearance, "", "Browse", null, true) });
            this.txtFilePath.Properties.ButtonClick += new ButtonPressedEventHandler(this.txtFilePath_Properties_ButtonClick);
            this.txtFilePath.Size = new Size(0x19b, 0x16);
            this.txtFilePath.TabIndex = 14;
            this.txtFilePath.TabStop = false;
            this.labelControl1.Appearance.Options.UseTextOptions = true;
            this.labelControl1.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.labelControl1.AutoSizeMode = LabelAutoSizeMode.None;
            this.labelControl1.Location = new Point(3, 3);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new Size(0x19b, 0x2e);
            this.labelControl1.TabIndex = 0;
            this.labelControl1.Text = "Điều chỉnh tập tin cần import c\x00f3 cấu tr\x00fac c\x00e1c trường dữ liệu giống như tập tin excel mẫu (xem tập tin mẫu theo đường dẫn b\x00ean dưới). Đảm bảo dữ liệu cột m\x00e3 nh\x00e2n vi\x00ean kh\x00f4ng tr\x00f9ng lấp nhau.";
            this.wpProcessPage.Controls.Add(this.lbDataRow);
            this.wpProcessPage.Controls.Add(this.labelControl3);
            this.wpProcessPage.Controls.Add(this.mqProgress);
            this.wpProcessPage.Name = "wpProcessPage";
            this.wpProcessPage.Size = new Size(0x1a1, 0xae);
            this.wpProcessPage.Text = "Tiến tr\x00ecnh thực hiện việc import dữ liệu";
            this.lbDataRow.AutoSizeMode = LabelAutoSizeMode.None;
            this.lbDataRow.Location = new Point(4, 0x68);
            this.lbDataRow.Name = "lbDataRow";
            this.lbDataRow.Size = new Size(0x199, 0x36);
            this.lbDataRow.TabIndex = 2;
            this.labelControl3.Appearance.Options.UseTextOptions = true;
            this.labelControl3.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.labelControl3.AutoSizeMode = LabelAutoSizeMode.None;
            this.labelControl3.Location = new Point(3, 4);
            this.labelControl3.Name = "labelControl3";
            this.labelControl3.Size = new Size(0x19b, 0x2e);
            this.labelControl3.TabIndex = 1;
            this.labelControl3.Text = manager.GetString("labelControl3.Text");
            this.mqProgress.EditValue = 0;
            this.mqProgress.Location = new Point(3, 0x4f);
            this.mqProgress.Name = "mqProgress";
            this.mqProgress.Properties.ProgressViewStyle = ProgressViewStyle.Solid;
            this.mqProgress.Size = new Size(410, 0x12);
            this.mqProgress.TabIndex = 0;
            this.wpFinish.AllowBack = false;
            this.wpFinish.Controls.Add(this.listboxError);
            this.wpFinish.Controls.Add(this.lbFix);
            this.wpFinish.Controls.Add(this.labelControl4);
            this.wpFinish.Controls.Add(this.lbMessage);
            this.wpFinish.Name = "wpFinish";
            this.wpFinish.Size = new Size(0x1a1, 0xae);
            this.wpFinish.Text = "Ho\x00e0n th\x00e0nh";
            this.listboxError.Appearance.ForeColor = Color.Red;
            this.listboxError.Appearance.Options.UseForeColor = true;
            this.listboxError.Location = new Point(3, 0x1b);
            this.listboxError.Name = "listboxError";
            this.listboxError.Size = new Size(0x19b, 0x6b);
            this.listboxError.TabIndex = 4;
            this.lbFix.AutoSize = true;
            this.lbFix.BackColor = Color.Transparent;
            this.lbFix.Font = new Font("Tahoma", 9.75f);
            this.lbFix.Location = new Point(0x16b, 4);
            this.lbFix.Name = "lbFix";
            this.lbFix.Size = new Size(0x33, 0x10);
            this.lbFix.TabIndex = 3;
            this.lbFix.TabStop = true;
            this.lbFix.Text = "Sửa Lỗi";
            this.lbFix.Visible = false;
            this.lbFix.LinkClicked += new LinkLabelLinkClickedEventHandler(this.lbFix_LinkClicked);
            this.lbMessage.AllowHtmlString = true;
            this.lbMessage.Location = new Point(3, 5);
            this.lbMessage.Name = "lbMessage";
            this.lbMessage.Size = new Size(0xb6, 14);
            this.lbMessage.TabIndex = 0;
            this.lbMessage.Text = "Th\x00e0nh c\x00f4ng: <color=red>0</color> mẫu tin. Lỗi: <color=red>0</color> mẫu tin.";
            this.wpSelectField.Controls.Add(this.gcList);
            this.wpSelectField.Name = "wpSelectField";
            this.wpSelectField.Size = new Size(0x1a1, 0xae);
            this.wpSelectField.Text = "Gh\x00e9p trường dữ liệu";
            this.gcList.Dock = DockStyle.Fill;
            this.gcList.Location = new Point(0, 0);
            this.gcList.MainView = this.gbList;
            this.gcList.Name = "gcList";
            this.gcList.RepositoryItems.AddRange(new RepositoryItem[] { this.repSelectField });
            this.gcList.Size = new Size(0x1a1, 0xae);
            this.gcList.TabIndex = 4;
            this.gcList.ViewCollection.AddRange(new BaseView[] { this.gbList });
            this.gbList.Columns.AddRange(new GridColumn[] { this.colFieldName, this.colSelectField });
            this.gbList.GridControl = this.gcList;
            this.gbList.Name = "gbList";
            this.gbList.OptionsView.ColumnAutoWidth = false;
            this.gbList.OptionsView.ShowGroupPanel = false;
            this.gbList.OptionsView.ShowIndicator = false;
            this.colFieldName.Caption = "Mặc định";
            this.colFieldName.FieldName = "FieldName";
            this.colFieldName.Name = "colFieldName";
            this.colFieldName.OptionsColumn.AllowEdit = false;
            this.colFieldName.OptionsColumn.ReadOnly = true;
            this.colFieldName.Visible = true;
            this.colFieldName.VisibleIndex = 0;
            this.colFieldName.Width = 0x9f;
            this.colSelectField.Caption = "T\x00f9y chọn";
            this.colSelectField.ColumnEdit = this.repSelectField;
            this.colSelectField.FieldName = "SelectField";
            this.colSelectField.Name = "colSelectField";
            this.colSelectField.Visible = true;
            this.colSelectField.VisibleIndex = 1;
            this.colSelectField.Width = 0xc0;
            this.repSelectField.AutoHeight = false;
            this.repSelectField.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.repSelectField.Name = "repSelectField";
            this.repSelectField.NullText = "<Vui l\x00f2ng chọn>";
            this.labelControl4.Appearance.Options.UseTextOptions = true;
            this.labelControl4.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.labelControl4.AutoSizeMode = LabelAutoSizeMode.None;
            this.labelControl4.Location = new Point(3, 0x8b);
            this.labelControl4.Name = "labelControl4";
            this.labelControl4.Size = new Size(0x19b, 0x20);
            this.labelControl4.TabIndex = 2;
            this.labelControl4.Text = "Qu\x00e1 tr\x00ecnh import dữ liệu nh\x00e2n vi\x00ean đ\x00e3 ho\x00e0n tất. Nhấn n\x00fat ho\x00e0n th\x00e0nh ph\x00eda b\x00ean dưới để x\x00e1c nhận lại.";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x1dd, 0x150);
            base.Controls.Add(this.wcImport);
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "xfmImport";
            base.ShowIcon = false;
            base.ShowInTaskbar = false;
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "Nhập Danh S\x00e1ch Nh\x00e2n Vi\x00ean Từ Tập Tin Excel";
            base.Load += new EventHandler(this.xfmImport_Load);
            this.wcImport.EndInit();
            this.wcImport.ResumeLayout(false);
            this.lcSheet.EndInit();
            this.lcSheet.ResumeLayout(false);
            this.cboSheet.Properties.EndInit();
            this.layoutControlGroup1.EndInit();
            this.layoutControlItem1.EndInit();
            this.wpSelectFile.ResumeLayout(false);
            this.wpSelectFile.PerformLayout();
            this.txtFilePath.Properties.EndInit();
            this.wpProcessPage.ResumeLayout(false);
            this.mqProgress.Properties.EndInit();
            this.wpFinish.ResumeLayout(false);
            this.wpFinish.PerformLayout();
            ((ISupportInitialize) this.listboxError).EndInit();
            this.wpSelectField.ResumeLayout(false);
            this.gcList.EndInit();
            this.gbList.EndInit();
            this.repSelectField.EndInit();
            base.ResumeLayout(false);
        }

        private void layoutControl1_Click(object sender, EventArgs e)
        {
        }

        private void lbFix_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                System.Diagnostics.Process.Start(this.txtFilePath.Text);
            }
            catch (Exception exception)
            {
                XtraMessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }

        private void lbLinkFile_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                System.Diagnostics.Process.Start(Application.StartupPath + @"\ImportFile\Employee.xls");
            }
            catch (Exception exception)
            {
                XtraMessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }

        private void RaiseSuccessEventHander()
        {
            if (this.Success != null)
            {
                this.Success(this);
            }
        }

        private void txtFilePath_Properties_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog {
                Filter = "Excel File(*.xls,*.xlsx)|*.xls;*.xlsx",
                FilterIndex = 0
            };
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                this.txtFilePath.Text = dialog.FileName;
            }
        }

        private void wcImport_NextClick(object sender, WizardCommandButtonClickEventArgs e)
        {
            this.m_Success = 0;
            this.m_Error = 0;
            if (e.Page == this.wpSelectFile)
            {
                if (this.txtFilePath.Text != "")
                {
                    this.FillSheet();
                }
                else
                {
                    XtraMessageBox.Show("Vui l\x00f2ng chọn đường dẫn đến tập tin dữ liệu!", "Th\x00f4ng B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
            if (e.Page == this.wpSelectField)
            {
                this.wcImport.SelectedPage = this.wpProcessPage;
                this.Refresh();
                this.listboxError.Items.Clear();
                this.Import();
                this.RaiseSuccessEventHander();
            }
        }

        private void wcImport_SelectedPageChanged(object sender, WizardPageChangedEventArgs e)
        {
            if (e.Page == this.wpSelectField)
            {
                this.lcSheet.Visible = true;
                if (this.txtFilePath.Text == "")
                {
                    this.wcImport.SelectedPage = this.wpSelectFile;
                }
            }
            else
            {
                this.lcSheet.Visible = false;
            }
        }

        private void xfmImport_Load(object sender, EventArgs e)
        {
        }

        private void xfmImport_Success(object sender)
        {
            this.wcImport.SelectedPage = this.wpFinish;
            this.lbMessage.Text = string.Concat(new object[] { "Th\x00e0nh c\x00f4ng: <color=red>", this.m_Success, "</color> mẫu tin. Lỗi: <color=red>", this.m_Error, "</color> mẫu tin." });
            if (this.m_Error > 0)
            {
                this.lbFix.Visible = true;
            }
        }

        public delegate void SuccessEventHander(object sender);
    }
}

